package form;

import java.util.ArrayList;

import javax.swing.JPanel;

public abstract class Form extends JPanel{
	
	private String formTitle;
	protected ArrayList<FormInputComponent> inputComponents;
	
	protected Form(){
		inputComponents = new ArrayList<FormInputComponent>();
	}
	
	public String getFormTitle(){
		return formTitle;
	}
	
	public void setFormTitle(String formTitle){
		this.formTitle = formTitle;
	}
	
	public String getInputFormatErrorMsg(){
		String errorMsg = "";
		String currError = "";
		for(int i=0;i<inputComponents.size();i++)
		{
			if(inputComponents.get(i) != null && !inputComponents.get(i).hasValidInput()){
				currError = inputComponents.get(i).getErrorMsg();
				if(currError!=null && !currError.equals(""))
					errorMsg+="\n"+currError;
			}
		}
		return errorMsg;
	}

	
	public abstract void clear();
	public abstract void refresh();
	
}
